package demo;

import java.util.Scanner;

public class Cpractise {
    //买飞机票
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入机票原价：");
        double money=sc.nextDouble();

        System.out.println("请输入月份(1~12)");
        int month=sc.nextInt();

        System.out.println("请选择舱位类型：");
        String type=sc.next();
        money=calc(money,month,type);

    }
    public static double calc(double money,int month,String type)
    {
         if(month>=5&&month<=10)
         {
             switch (type) {
                 case "头等舱": money = money * 9 / 10;
                     System.out.println("您的价格是："+money);
                     break;
                 case "经济舱": money=money*85/100;
                     System.out.println("您的价格是："+money);
                     break;
                 default:
                     System.out.println("您的舱位输入有误！");
                     break;
             }
             return money;
         }
         else if(month>=1&&month<=4||month==11||month==12)
         {
             switch (type) {
                 case "头等舱": money = money * 7 / 10;
                     System.out.println("您的价格是："+money);
                     break;
                 case "经济舱": money=money*65/100;
                     System.out.println("您的价格是："+money);
                     break;
                 default:
                     System.out.println("您的舱位输入有误！");
                     break;
             }
             return money;
         }
         else
         {
             System.out.println("您输入的月份有误！请重新输入！");
             return -1;
         }
    }
}
